package com.ssm.web.action;

import static com.opensymphony.xwork2.Action.SUCCESS;

import java.util.ArrayList;
import java.util.List;

import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.ssm.dao.mybatis.employee.service.IEmployeeMybatisService;
import com.ssm.dto.mybatis.Employee;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;

@ParentPackage("custom-default")
@Results({ @Result(name = SUCCESS, location = "/success.jsp"),
		@Result(name = "struts-default-vm", location = "/success.jsp") })
public class LoginAction extends ActionSupport {
	private Logger LOG = LoggerFactory.getLogger(LoginAction.class);
	private static final long serialVersionUID = 1L;
	private IEmployeeMybatisService employeeMybatisService;
	private List<Employee> list = new ArrayList<Employee>();
	Employee employee = new Employee();
	public String msg = "";

	public String login() {
		LOG.debug("-----name:[" + employee.getName() + "]\tpassword:["
				+ employee.getPassword() + "]");
		list = employeeMybatisService.findEmployee(employee);
		return SUCCESS;
	}

	public String execute() {
		return "struts-default-vm";
	}

	public IEmployeeMybatisService getEmployeeMybatisService() {
		return employeeMybatisService;
	}

	public void setEmployeeMybatisService(
			IEmployeeMybatisService employeeMybatisService) {
		this.employeeMybatisService = employeeMybatisService;
	}

	public List<Employee> getList() {
		return list;
	}

	public void setList(List<Employee> list) {
		this.list = list;
	}

	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

}
